<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet
	version = "1.0"
	xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">

	<xsl:output
		method = "xml"
		version = "1.0"
		encoding = "UTF-8"
		indent = "yes"
		doctype-public = "-//W3C//DTD XHTML 1.1//EN"
		doctype-system = "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
		media-type = "application/xhtml+xml"/>

	<xsl:template match = "/">
		<xsl:element name = "opzioni">
			<xsl:element name = "ul">
				<xsl:attribute name = "class">
					<xsl:text>combo</xsl:text>
				</xsl:attribute>
				<xsl:apply-templates select = "//layout"/>
			</xsl:element>
		</xsl:element>
	</xsl:template>


	<xsl:template match = "layout">
		<xsl:element name = "li">
			<xsl:value-of select = "@id"/>
			<xsl:element name = "ul">
				<xsl:apply-templates select = "skin"/>
			</xsl:element>
		</xsl:element>
	</xsl:template>


	<xsl:template match = "skin">
		<xsl:element name = "li">
			<xsl:attribute name = "title">
				<xsl:value-of select = "descrizione"/>
			</xsl:attribute>

			<xsl:attribute name = "onclick">
				<xsl:apply-templates select = "ancestor::*/@type"/>
				<xsl:text>(</xsl:text>
					<xsl:value-of select = "ancestor::*/@df"/>
				<xsl:text>, "</xsl:text>
					<xsl:value-of select = "parent::layout/@id"/>
				<xsl:text>", "</xsl:text>
					<xsl:value-of select = "@id"/>
				<xsl:text>")</xsl:text>
			</xsl:attribute>

			<xsl:value-of select = "@id"/>
		</xsl:element>
	</xsl:template>


	<xsl:template match = "@type">
		<xsl:choose>
			<xsl:when test = "contains(., 'pdf')">
				<xsl:text>UISaveBinDocument</xsl:text>
			</xsl:when>
			<xsl:otherwise>
				<xsl:text>UIChangeTagFormatter</xsl:text>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

</xsl:stylesheet>
